package com.killer.service.Impl;


import com.killer.enums.ResultCode;
import com.killer.enums.TaskStatus;
import com.killer.enums.TaskStatusChangeEvent;


import com.killer.pojo.entity.Message;
import com.killer.service.MessageService;
import com.killer.service.TaskService;
import com.killer.untils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.sound.midi.MetaMessage;

@Slf4j
@Service
public class TaskServiceImpl implements TaskService {


    @Autowired
    private MessageService messageService;




    @Override
    public void export(int taskId) {

    }

    @Override
    public void finish(int taskId) {

    }

    @Override
    public Result getTaskStatus(Message message) {
        if(message.getStatus() == TaskStatus.FINISH.getKey()){
            return new Result(TaskStatus.FINISH.getKey(), TaskStatus.FINISH.getDesc(),null);
        }else if (message.getStatus() == TaskStatus.FAILED.getKey()){
            return new Result(TaskStatus.FAILED.getKey(), TaskStatus.FAILED.getDesc(),null);
        }else if (message.getStatus() == TaskStatus.EXPORT.getKey()){
            return new Result(TaskStatus.EXPORT.getKey(),TaskStatus.EXPORT.getDesc(),null);
        }else {
            return new Result(TaskStatus.CREATE.getKey(), TaskStatus.CREATE.getDesc(),null);
        }
    }


}
